/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.widget;

import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

import org.jetbrains.annotations.NotNull;

import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import com.xuexiang.templateproject.R;
import com.xuexiang.xrouter.utils.TextUtils;

public class BottomDialog  extends Dialog {
    @NotNull

    /* renamed from: a  reason: collision with root package name */
    public Context f14206a;
    @NotNull

    /* renamed from: b  reason: collision with root package name */
    public OnSaveOnClickListener onSaveOnClickListener;

    /* compiled from: BottomDialog.kt */
    @Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&¨\u0006\u0006"}, d2 = {"Lcom/jcds/learneasy/dialog/BottomDialog$SaveOnClickListener;", "", "onSaveOnClickListener", "", "subjectName", "", "app_huaweiRelease"}, k = 1, mv = {1, 7, 1}, xi = 48)
    /* loaded from: classes2.dex */
    public interface OnSaveOnClickListener {
        void onSaveClick(@NotNull String str);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public BottomDialog(@NotNull Context c2, @NotNull OnSaveOnClickListener saveOnClickListener) {
        super(c2, R.style.bottom_dialog);
        Intrinsics.checkNotNullParameter(c2, "c");
        Intrinsics.checkNotNullParameter(saveOnClickListener, "saveOnClickListener");
        this.f14206a = c2;
        this.onSaveOnClickListener = saveOnClickListener;
        setContentView(R.layout.layout_bottom_dialog);
        Window window = getWindow();
        WindowManager.LayoutParams attributes = window != null ? window.getAttributes() : null;
        if (attributes != null) {
            attributes.gravity = 80;
        }
        Context context = this.f14206a;
        Intrinsics.checkNotNull(context, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        Display defaultDisplay = ((AppCompatActivity) context).getWindowManager().getDefaultDisplay();
        if (attributes != null) {
            attributes.width = defaultDisplay.getWidth();
        }
        Window window2 = getWindow();
        if (window2 != null) {
            window2.setAttributes(attributes);
        }
        Window window3 = getWindow();
        if (window3 != null) {
            window3.clearFlags(131080);
        }
        Window window4 = getWindow();
        if (window4 != null) {
            window4.setSoftInputMode(20);
        }
        initView();
    }

    public static final void tap(BottomDialog this$0, View view) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        String obj = ((EditText) this$0.findViewById(R.id.edtName)).getText().toString();
        if (!TextUtils.isEmpty(obj)) {
            this$0.onSaveOnClickListener.onSaveClick(obj);
        }
    }

    public final void initView() {
        ((Button) findViewById(R.id.btnSave)).setOnClickListener(new View.OnClickListener() { // from class: d.m.b.g.a
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                BottomDialog.tap(BottomDialog.this, view);
            }
        });
    }

    public final void updateCourseName(@NotNull String courseName) {
        Intrinsics.checkNotNullParameter(courseName, "courseName");
        int i2 = R.id.edtName;
        ((EditText) findViewById(i2)).setText(courseName);
        ((EditText) findViewById(i2)).setSelection(courseName.length());
    }

    public final void setSaveOnClickListener(@NotNull OnSaveOnClickListener aVar) {
        Intrinsics.checkNotNullParameter(aVar, "<set-?>");
        this.onSaveOnClickListener = aVar;
    }

}
